package 华为OD机试B卷复用题.基础题;

import utils.MyUtil;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ12_补种未成活胡杨 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试B卷复用题/基础题/input/12.txt"));
        MyUtil.START();
        Solution(in);
        MyUtil.END();
    }

    // 滑动窗口
    static void Solution(Scanner in) {
        int N = in.nextInt();
        int M = in.nextInt();
        Map<Integer, Boolean> dead = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int deadTree = in.nextInt();
            dead.put(deadTree, true);
        }
        int buzhong = in.nextInt();
        int right = 1;
        int left = 1;
        int tmpDead = 0;
        if (dead.getOrDefault(1, false)) {
            tmpDead = 1;
        }
        int tmpSize = 1;
        int maxSize = 1;
        int[] res = new int[2];
        while (right <= N) {
            if (tmpDead > buzhong) {
                while (tmpDead > buzhong) {
                    if (dead.getOrDefault(left, false)) {
                        tmpDead--;
                    }
                    left++;
                    tmpSize--;
                }
            }
            //            maxSize = Math.max(maxSize, tmpSize);
            if (tmpSize > maxSize) {
                maxSize = tmpSize;
                res[0] = left;
                res[1] = right;
            }
            if (right == N) {
                break;
            }
            right++;
            tmpSize++;
            if (dead.getOrDefault(right, false)) {
                tmpDead++;
            }
        }
        System.out.println(maxSize);
        System.out.println(res[0] + " " + res[1]);
    }
}
